/*Copyright*/
package com.jmex.physics.material;

import com.jmex.physics.contact.ContactCallback;
import com.jmex.physics.contact.ContactHandlingDetails;
import com.jmex.physics.contact.PendingContact;

/**
 * A helper class used internally to apply info from materials to contacts.
 * @author Irrisor
 */
public class MaterialContactCallback implements ContactCallback {
    private MaterialContactCallback() {
    }

    private static final MaterialContactCallback instance = new MaterialContactCallback();

    public static MaterialContactCallback get() {
        return instance;
    }

    public boolean adjustContact( PendingContact contact ) {
        Material m1 = contact.getGeometry1().getMaterial();
        Material m2 = contact.getGeometry2().getMaterial();
        ContactHandlingDetails details = m1.getContactHandlingDetails( m2 );
        if ( details != null ) {
            contact.copy( details );
            return true;
        }
        else {
            return false;
        }
    }
}

/*
 * $log$
 */

